define(["jquery","bbcare",
    "scprit/followup/app/motionAndBG/motionAndBG.ui.js",
    "scprit/followup/app/motionAndBG/motionAndBG.event.js",
    "scprit/followup/app/motionAndBG/motionAndBG.servers.js"],function ($,$bb,$ui,$event,$servers) {
    var motion = {};
    /*
     * 获取建档问卷的回调
     * */
    var getRecordQuestionsCallback = function(data){
        data.data.patientInfo.pregnancyStatus = data.data.values["profile0016"];
        data.data.patientInfo.bookNo = data.data.values["341200007"];
        data.data.patientInfo.lmp = data.data.values["Pub13x00001"];
        $ui.babyInfoInit({"id":"#info-box","data":data.data.patientInfo});
    };
    /*
     * 获取任务id列表的回调
     * */
    var getTaskIdCallback = function(data,params){
        var rows = data.data.rows,taskId;
        for(var i = 0;i < rows.length;i++){
            if(rows[i].seqNo == 0){
                taskId = rows[i].taskId;
                break;
            }
        }
        var inParams = {"followQueueId":params.followQueueId,"ptTaskId":taskId};
        $servers.getRecordQuestions(inParams,getRecordQuestionsCallback);
    };
    motion.init = function(){
        var getParams = $bb.getPageParams();

        /*
        * 获取顶部基本信息：
        * */
        var params = {followQueueId:getParams.followQueueId,patientSchemeId:getParams.patientSchemeId};
        $servers.getTaskId(params,getTaskIdCallback,getParams);

        $event.init(getParams);

        $(function(){
            $(window).resize(function(){
                var width=$("#motionCur").width();
                $("#motionCur >  div").css({"width":width});
                $("#motionCur >  div > canvas").css({"width":width});
            });
        });
    };
    return motion;
});